#!/usr/bin/env python
import sys
from lib.format_time import *
from lib.HandleMysql import *
from lib.switch_code import *
from shop_conn import *
import sys
import re
import os
sys.setdefaultencoding('utf-8')

def execute(  ):    
    query = ""
    conn = set_shop_conn()
    stat_conn = set_stats_conn()
    stat_table = "shop_info"
    #
    query = "select ifnull(max(shop_id),0) from t_shop"
    items = stat_conn.get_results(query)
    maxid = items[0][0]
    
    print maxid
    query = "select id from shop where id>%s "%maxid
    items = conn.get_results(query)
    for item in items:
        shop_id = item[0]
        
        sql = "insert into t_shop(shop_id) values(%s)"%shop_id
        stat_conn.execute_sql(sql)

if __name__=='__main__':
    execute( )